package com.oweight.sagacious.auth.client.feign;

import com.oweight.sagacious.api.model.msg.Message;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 去鉴权服务获取相关信息
 *
 * @author SAGE
 * @version v1 2019/10/19 14:18
 */
@FeignClient(value = "${auth.serviceId}")
public interface ServiceAuthFeign {

    /**
     * 获取访问Token
     *
     * @param clientId 客户端ID
     * @param secret   密钥
     * @return
     */
    @RequestMapping(value = "/client/token", method = RequestMethod.POST)
    Message getAccessToken(@RequestParam("clientId") String clientId, @RequestParam("secret") String secret);

    /**
     * 获取所有授权的客户端
     *
     * @param serviceId 服务端ID
     * @param secret    密钥
     * @return
     */
    @RequestMapping(value = "/client/myClient")
    Message getAllowedClient(@RequestParam("serviceId") String serviceId, @RequestParam("secret") String secret);

    /**
     * 获取服务公钥
     *
     * @param clientId 客户端ID
     * @param secret   密钥
     * @return
     */
    @RequestMapping(value = "/client/servicePubKey", method = RequestMethod.POST)
    byte[] getServicePublicKey(@RequestParam("clientId") String clientId, @RequestParam("secret") String secret);

    /**
     * 获取用户公钥
     *
     * @param clientId 客户端ID
     * @param secret   密钥
     * @return
     */
    @RequestMapping(value = "/client/userPubKey", method = RequestMethod.POST)
    byte[] getUserPublicKey(@RequestParam("clientId") String clientId, @RequestParam("secret") String secret);

}
